// import com.alibaba.druid.DbType;
// import com.alibaba.druid.sql.SQLUtils;
// import com.alibaba.druid.sql.ast.*;
// import com.alibaba.druid.sql.ast.SQLParameter.ParameterType;
// import com.alibaba.druid.sql.ast.expr.*;
// import com.alibaba.druid.sql.ast.statement.*;
// import com.alibaba.druid.sql.dialect.mysql.ast.*;
// import com.alibaba.druid.sql.dialect.mysql.ast.clause.*;
// import com.alibaba.druid.sql.dialect.mysql.ast.clause.ConditionValue.ConditionType;
// import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlCaseStatement.MySqlWhenStatement;
// import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlUserName*;
// import com.alibaba.druid.sql.dialect.mysql.ast.statement.*;
// import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLockTableStatement.LockType;
// import com.alibaba.druid.sql.parser.*;
// import com.alibaba.druid.sql.repository.SchemaObject;
// import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;
// import com.alibaba.druid.util.FnvHash;
// import com.alibaba.druid.util.std::stringUtils;

// import java.util.Arraystd::list;
// import java.util.std::list;

// import static com.alibaba.druid.sql.parser.Token::*;
#pragma once
#include <string>
#include <list>
#include <ctime>
#include "../../../parser/SQLStatementParser.h"

class SQLParserFeature;
class SQLCreateTableStatement;
class SQLUpdateStatement;
class MySqlUpdateStatement;
// class MySqlDeleteStatement;
// class SQLCreateIndexStatement;
// class MySqlAnalyzeStatement;
// class MySqlOptimizeStatement;
// class SQLBeginStatement;
// class SQLBlockStatement;
// class MySqlExplainStatement;
// class MySqlShowStatusStatement;
// class MySqlShowSlowStatement;
// class MySqlShowWarningsStatement;
// class SQLStartTransactionStatement;
// class SQLReplaceStatement;
// class MySqlLoadXmlStatement;
// class SQLWhileStatement;
// class MySqlLoadDataInFileStatement;
// class MySqlPrepareStatement;
// class MySqlExecuteStatement;
// class MySqlExecuteForAdsStatement;
// class MysqlDeallocatePrepareStatement;
// class SQLInsertStatement;
class MySqlSelectParser;
// class MySqlEventSchedule;
// class SQLAlterTableStatement;
// class MySqlExtPartition;
// class SQLAlterCharacter;
// class MySqlAlterUserStatement;
// class MySqlExprParser;
// class SQLCreateFunctionStatement;
// class SQLCreateProcedureStatement;
// class SQLParameter;
// class MySqlChecksumTableStatement;
class SQLIfStatement;
// class MySqlCaseStatement;
class SQLSetStatement;
// class MySqlSelectIntoStatement;
class SQLLoopStatement;
// class MySqlLeaveStatement;
// class MySqlIterateStatement;
// class MySqlRepeatStatement;
// class MySqlCursorDeclareStatement;
// class MySqlDeclareHandlerStatement;
// class MySqlDeclareConditionStatement;
class MySqlCreateTableParser;

class MySqlStatementParser : public SQLStatementParser
{
public:
  static string_ptr AUTO_INCREMENT;
  static string_ptr AVG_ROW_LENGTH;
  static string_ptr CHECKSUM2;
  static string_ptr DELAY_KEY_WRITE;
  static string_ptr ENCRYPTION2;
  static string_ptr INSERT_METHOD;
  static string_ptr KEY_BLOCK_SIZE2;
  static string_ptr MAX_ROWS2;
  static string_ptr MIN_ROWS2;
  static string_ptr PASSWORD2;
  static string_ptr STATS_AUTO_RECALC;
  static string_ptr STATS_PERSISTENT;
  static string_ptr STATS_SAMPLE_PAGES;
  static string_ptr TABLESPACE2;
  static string_ptr CHAIN;
  static string_ptr ENGINES;
  static string_ptr ENGINE;
  static string_ptr BINLOG;
  static string_ptr EVENTS;
  static string_ptr GLOBAL;
  static string_ptr VARIABLES;
  static string_ptr STATUS;
  static string_ptr DBLOCK;
  static string_ptr RESET;
  static string_ptr DESCRIBE;
  static string_ptr WRITE;
  static string_ptr READ;
  static string_ptr LOCAL;
  static string_ptr TABLES;
  static string_ptr CONNECTION;

  int maxIntoClause = -1;

  MySqlStatementParser(string_ptr sql);

  MySqlStatementParser(string_ptr sql, SQLParserFeature_list_ptr features);

  MySqlStatementParser(string_ptr sql, BOOL_ptr keepComments);

  MySqlStatementParser(string_ptr sql, BOOL_ptr skipComment, BOOL_ptr keepComments);

  MySqlStatementParser(Lexer_ptr lexer);

  int getMaxIntoClause();

  void setMaxIntoClause(int maxIntoClause);

  SQLCreateTableStatement_ptr parseCreateTable() /*override*/;

  SQLStatement_ptr parseSelect() override;

  SQLUpdateStatement_ptr parseUpdateStatement() override;

  SQLUpdateStatement_ptr createUpdateStatement() override;

  // MySqlDeleteStatement* parseDeleteStatement() override;

  SQLStatement_ptr parseCreate() override;

  SQLStatement_ptr parseCreateFullTextStatement();

  SQLStatement_ptr parseFullTextAnalyzer();

  SQLStatement_ptr parseFullTextTokenizer();

  SQLStatement_ptr parseFullTextCharFilter();

  SQLStatement_ptr parseFullTextTokenFilter();

  SQLStatement_ptr parseCreateOutline();

  SQLStatement_ptr parseCreateTableSpace();

  SQLStatement_ptr parseCreateServer();

  // SQLCreateIndexStatement* parseCreateIndex(BOOL_ptr acceptCreate) override;

  // void parseCreateIndexUsing(SQLCreateIndexStatement* stmt);

  SQLStatement_ptr parseCreateUser();

  SQLStatement_ptr parseKill();

  SQLStatement_ptr parseBinlog();

  // MySqlAnalyzeStatement* parseAnalyze() ;

  // MySqlOptimizeStatement* parseOptimize() ;

  SQLStatement_ptr parseReset();

  BOOL_ptr parseStatementListDialect(SQLStatement_list_ptr statementList) /* override */;

  SQLStatement_ptr parseArchive();

  SQLStatement_ptr parseBackup();

  SQLStatement_ptr parseRestore();

  SQLStatement_ptr parseBuildTable();

  SQLStatement_ptr parseCancelJob();
  SQLStatement_ptr parseExportTable();
  SQLStatement_ptr parseExportDB();
  SQLStatement_ptr parseRaftLeaderTransfer();
  SQLStatement_ptr parseRaftMemeberChange();
  SQLStatement_ptr parseMigrate();
  SQLStatement_ptr parseImportDB();
  SQLStatement_ptr parseImportTable();
  SQLStatement_ptr parseSubmitJob();
  SQLStatement_ptr parseSync();
  SQLStatement_ptr parseFlush();

  // SQLBeginStatement* parseTiDBBeginStatment() ;

  // MySqlExplainStatement* parseDescribe() ;

  // MySqlExplainStatement* parseExplain() override;

  // MySqlExplainStatement* parseExplain(MySqlExplainStatement* explain) ;

  SQLStatement_ptr parseShow() override;

  // MySqlShowStatusStatement parseShowStatus() ;

  // MySqlShowSlowStatement parserShowSlow() ;

  // MySqlShowWarningsStatement parseShowWarnings() ;

  // SQLStartTransactionStatement* parseStart() ;

  SQLStatement_ptr parseRollback() override;

  SQLStatement_ptr parseCommit() override;

  // SQLReplaceStatement* parseReplace() ;

  SQLStatement_ptr parseLoad();

  // MySqlLoadXmlStatement parseLoadXml() ;

  // MySqlLoadDataInFileStatement parseLoadDataInFile() ;

  // MySqlPrepareStatement parsePrepare() ;

  // MySqlExecuteStatement parseExecute() ;

  // MySqlExecuteForAdsStatement parseExecuteForAds() ;

  // MysqlDeallocatePrepareStatement parseDeallocatePrepare() ;

  // SQLInsertStatement_ptr parseInsert();
  SQLStatement_ptr parseInsert() override;

  MySqlSelectParser_ptr createSQLSelectParser();

  SQLStatement_ptr parseSet() override;
  SQLStatement_ptr parseAlter() override;
  SQLStatement_ptr parseAddManageInstanceGroup();
  SQLStatement_ptr parseAlterFullTextCharFilter();
  SQLStatement_ptr parseAlterTableGroup();
  SQLStatement_ptr parseAlterSystem();
  SQLStatement_ptr parseAlterOutline();
  SQLStatement_ptr parseAlterView();
  SQLStatement_ptr parseAlterTableSpace();
  SQLStatement_ptr parseAlterServer();
  SQLStatement_ptr parseCreateLogFileGroup();
  SQLStatement_ptr parseAlterLogFileGroup();
  SQLStatement_ptr parseAlterProcedure();
  SQLStatement_ptr parseAlterFunction();
  SQLStatement_ptr parseCreateEvent();
  SQLStatement_ptr parseAlterEvent();

  // MySqlEventSchedule parseSchedule() ;

  // BOOL_ptr parseAlterSpecification(SQLAlterTableStatement stmt) ;

  SQLStatement_ptr parseAlterTable(BOOL_ptr ignore, BOOL_ptr online, BOOL_ptr offline);

  /*
  SQLStatement_ptr  parseAlterTableOld(BOOL_ptr ignore) ;
  */

  // MySqlExtPartition parseExtPartition() ;

  // SQLAlterCharacter alterTableCharacter() ;

  // void parseAlterTableAddColumn(SQLAlterTableStatement stmt) ;

  // void parseAlterDrop(SQLAlterTableStatement* stmt) override;

  SQLStatement_ptr parseRename() override;
  SQLStatement_ptr parseCreateDatabase() override;

  void parseUpdateSet(SQLUpdateStatement_ptr update) override;

  SQLStatement_ptr parseAlterDatabase();

  // MySqlAlterUserStatement* parseAlterUser() ;

  // MySqlExprParser* getExprParser() ;

  // SQLCreateFunctionStatement* parseCreateFunction() ;

  /*
   * parse create procedure statement
   */
  // SQLCreateProcedureStatement* parseCreateProcedure() ;

  /*
   * parse create procedure parameters
   *
   * @param parameters
   */
  // void parserParameters(std::list<SQLParameter*> parameters, SQLObject_ptr  parent) ;

  /*
   * parse procedure statement block
   *
   * @param statementstd::list
   */
  void parseProcedureStatementList(SQLStatement_list_ptr statementList);

  /*
   * parse procedure statement block
   */
  void parseProcedureStatementList(SQLStatement_list_ptr statementList, int max);

  // MySqlChecksumTableStatement* parseChecksum() ;

  /*
   * parse if statement
   *
   * @return MySqlIfStatement
   */
  SQLIfStatement *parseIf();

  /*
   * parse while statement
   *
   * @return MySqlWhileStatement
   */
  SQLWhileStatement_ptr parseWhile();

  /*
   * parse while statement with label
   *
   * @return MySqlWhileStatement
   */
  SQLWhileStatement_ptr parseWhile(string_ptr label);

  /*
   * parse case statement
   *
   * @return MySqlCaseStatement
   */
  // MySqlCaseStatement* parseCase() ;

  /*
   * parse declare statement
   */
  SQLStatement_ptr parseDeclare();

  /*
   * parse assign statement
   */
  SQLSetStatement *parseAssign();

  /*
   * parse select into
   */
  // MySqlSelectIntoStatement* parseSelectInto() ;

  /*
   * parse loop statement
   */
  SQLLoopStatement_ptr parseLoop();

  /*
   * parse loop statement with label
   */
  SQLLoopStatement_ptr parseLoop(string_ptr label);

  SQLStatement_ptr parseBlock() override;
  /*
   * parse loop statement with label
   */
  SQLStatement_ptr parseBlock(string_ptr label);

  /*
   * parse leave statement
   */
  // MySqlLeaveStatement* parseLeave() ;

  /*
   * parse iterate statement
   */
  // MySqlIterateStatement* parseIterate() ;

  /*
   * parse repeat statement
   */
  MySqlRepeatStatement_ptr parseRepeat();

  /*
   * parse repeat statement with label
   *
   * @param label
   */
  MySqlRepeatStatement_ptr parseRepeat(string_ptr label);

  /*
   * parse cursor declare statement
   */
  // MySqlCursorDeclareStatement* parseCursorDeclare() ;

  /*
   * zhujun [455910092@qq.com]
   * parse spstatement
   */
  SQLStatement_ptr parseSpStatement();

  /*
   * 定义异常处理程序
   *
   * @author zhujun [455910092@qq.com]
   * 2016-04-16
   */
  // MySqlDeclareHandlerStatement* parseDeclareHandler() ;

  /*
   * zhujun [455910092@qq.com]
   * 2016-04-17
   * 定义条件
   */
  // MySqlDeclareConditionStatement* parseDeclareCondition() ;

  SQLStatement_ptr parseFlashback();

  time_t getCurrentTimestamp();

  time_t getCurrentDate();

  MySqlCreateTableParser *getSQLCreateTableParser();

  SQLStatement_ptr parseCopy();
};
